/* 
    1700. 无法吃午餐的学生数量
*/
/**
 * @param {number[]} students
 * @param {number[]} sandwiches
 * @return {number}
 */
// 暴力
var countStudents = function (students, sandwiches) {
	for (let i = 0; i < students.length; i++) {
		const first = students.shift()
		if (first !== sandwiches[i]) {
			students.push(first)
		} else {
			sandwiches.shift()
		}
		const hasNext = students.includes(sandwiches[0])
		if (hasNext) {
			i--
		} else break
	}
	return students.length
}
var countStudents = function (students, sandwiches) {
	// 喜欢吃方形三明治的学生数量学生
	let s1 = students.reduce((prev, next) => prev + next, 0)
	// 喜欢吃圆形三明治的学生数量
	let s0 = students.length - s1
	debugger
	for (let i = 0; i < sandwiches.length; i++) {
		if (sandwiches[i] === 0 && s0 > 0) {
			s0--
		} else if (sandwiches[i] === 1 && s1 > 0) {
			s1--
		} else break
	}
	return s0 + s1
}
const number = countStudents([1, 1, 1, 0, 0, 1], [1, 0, 0, 0, 1, 1])
console.log('countStudents :>>', number)
